<?php 
$bedroom    = Model_Listing_Residential::getBedroomPostAd();
$other_room = Model_Listing_Residential::getOtherRoomPostAd();
$toilet     = Model_Listing_Residential::getToilet();
$tmp = $this->listing->bedroom;

$bedrooms = '';
if (!empty($tmp)) {
    if ($tmp < 0) {
        $tmp = 99;
    }
    //if (in_array($tmp, $bedroom)) {
        $val = Ac_Util::getChineseNumber($tmp);
        $bedrooms = ($bedroom[$tmp] > 1) ? $val . '卧室' : $val . '卧室';
   //}
}

$tmp = $this->listing->other_room;
$other_rooms = '';
if (!empty($tmp)) {
    if ($tmp < 0) {
        $tmp = 99;
    }
    //if (in_array($tmp, $other_room)) {
        $val = Ac_Util::getChineseNumber($tmp);
        $other_rooms = ($other_room[$tmp] > 1) ? $val . '厅' : $val . '厅';
    //}
}


$tmp = $this->listing->bathroom;
$toilets = '';
if (!empty($tmp)) {
    if ($tmp < 0) {
        $tmp = 99;
    }
    //if (in_array($tmp, $toilet)) {
        $val = Ac_Util::getChineseNumber($tmp);
        $toilets = ($toilet[$tmp] > 1) ? $val . '卫生间' : $val . '卫生间';
    //}
}
$line1 = $line2 = $line3= '';

?>
<dd class="detail">
    <?php 
    $to_add  = '';
    if (!empty($this->listing->area_l2) && !empty($this->listing->area_l2->area_l1)) {
        $area_name = $this->listing->area_l2->area_l1->name;
        $line1 = '<a href="'.Ac_Util::getCrossLink($this->listing->area_l2->area_l1->_id, 'area_l1', $this->listing).'">'.$area_name.'</a>';
        $to_add = ', ';
    }

    if (!empty($this->listing->area_l2)) {
        $distric_name = $this->listing->area_l2->name;
        $line1 .= $to_add . '<a href="'.Ac_Util::getCrossLink($this->listing->area_l2->_id, 'area_l2', $this->listing).'">'.$distric_name.'</a>';
        $to_add = ', ';
    }
     
    if (!empty($this->listing->street)) { 
        $line1 .= $to_add . trim($this->listing->street);
        $to_add = ', ';
    }
                
    $to_add = '';
    if (!empty($bedrooms) && !empty($this->listing->bedroom) && !empty($bedroom)) {
        $line2 = '<a href="'.Ac_Util::getCrossLink($this->listing->bedroom, 'bedroom', $this->listing).'">'.$bedrooms.'</a>';
        $to_add = ', ';
    }

    if (!empty($other_rooms) && !empty($this->listing->bedroom) && !empty($other_room)) {
        $line2 .= $to_add . '<a href="'.Ac_Util::getCrossLink($this->listing->other_room, 'other_room', $this->listing).'">'.$other_rooms.'</a>';
        $to_add = ', ';
    }

    if (!empty($toilets) && !empty($this->listing->bathroom) && !empty($toilet)) {
        $line2 .= $to_add . '<a href="'.Ac_Util::getCrossLink($this->listing->bathroom, 'toilet', $this->listing).'">'.$toilets.'</a>';
        $to_add = ', ';
    }

    if (!empty($this->listing->size)){
        $line3 = $this->t('__1__平方米', null, number_format($this->listing->size));
    }
    
    echo $line1;
    echo (!empty($line1) && !empty($line2)) ? '<br>' : '';
    echo $line2;
    echo ((!empty($line1) || !empty($line2)) && !empty($line3)) ? '<br>' : '';
    echo $line3;    
    ?>
</dd>

<?php 
/*$attribs = Model_Listing_Attribute::all();
$count = 0;
foreach($attribs as $attrib){
	if(empty($attrib->nm_sc) && !empty($attrib->nm_en)){
		//echo $attrib->nm_sc ." - ". $attrib->nm_en."<br>"; 
		$count++;
		$attrib->nm_sc = $attrib->nm_en;
		$attrib->save();
	}
}
echo $count."xxxxxxxxxxxx";*/
?>